package org.cp.dao.k8.impl;

import java.util.List;

import org.cp.dao.BaseDAO;
import org.cp.dao.k8.IK8GuessDAO;
import org.cp.vo.Guessnumber;
import org.cp.vo.Guesssumresult;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

public class K8GuessDAO extends BaseDAO implements IK8GuessDAO {

	public void insertGNumber(Guessnumber guessNumber) {
		Session session = getSession();
		Transaction tx = session.beginTransaction();
		session.save(guessNumber);
		tx.commit();
		session.close();
	}

	public void insertGResult(Guesssumresult guessSumResult) {
		Session session = getSession();
		Transaction tx = session.beginTransaction();
		session.save(guessSumResult);
		tx.commit();
		session.close();

	}

	public List SearchByhql(String hql) {
		Session session = getSession();
		Query query = session.createQuery(hql);
		List results = query.list();
		if(results.size() != 0){
			return results;
		}
		session.close();
		return null;
	}
}
